package com.liruo.test.spring.annotationdep;

import com.liruo.test.spring.annotationdep.bean.id.BeanAnnotationAppoint;
import com.liruo.test.spring.annotationdep.bean.id.InterfaceAppoint;
import com.liruo.test.spring.annotationdep.component.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:liruo
 * @Date:2022-11-20-10:25:45
 * @Desc
 */
//专门用ComponentScanAnnotationParser来解析
//@ComponentScan(
//        //默认当前包，如果指定了其他包，那么就没有当前包了，如果需要要手动指定(即便是不指定包，配置类下的bean也都会被注册)
//        //  指定包是只扫描component注解(Controller等也包含了component)
//        basePackages = {
//                "com.liruo.test.spring.component.common.model",
//                "com.liruo.test.spring.annotationdep"
//        }
////       根据TypeFilterUtils的createTypeFiltersFor方法，目前只支持注解，指定类和自定义
//        //根据注解  ANNOTATION
////        excludeFilters = {@ComponentScan.Filter(type= FilterType.ANNOTATION,classes={Controller.class})}
////        useDefaultFilters = false, //includeFilters需要useDefaultFilters = false
////        includeFilters = {@ComponentScan.Filter(type= FilterType.ANNOTATION,classes={Repository.class})},//只包含
//        //根据类型  ASSIGNABLE_TYPE ----不用注解也可以注册，给指定类型加一个bean到ioc中
////        includeFilters = {@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE,classes={User.class, CommonModel1.class})}
////        includeFilters = {@ComponentScan.Filter(type= FilterType.CUSTOM,classes={CustomizeFilterType.class})}
//)
//Configuration注解的类一定会被解析，不管有没有ComponentScan注解
@Configuration
//@ComponentScan("com.liruo.test.spring.component.third.mainotherconfig")
public class ComponentScanConfiguration {
    @Bean
    public User user1ByConfiguration(){
        User user = new User();
        user.setName("user1");
        return user;
    }
//    @Bean
//    public AnnotationInClassAppoint annotationInClassAppoint(){
//        return new AnnotationInClassAppoint();
//    }
    @Bean
    public BeanAnnotationAppoint beanAnnotationAppoint(){
        return new BeanAnnotationAppoint();
    }
    @Bean
    public InterfaceAppoint interfaceAppoint(){
        return new InterfaceAppoint();
    }


    /**
     * @{link org.springframework.context.annotation.ConfigurationClassParser#processMemberClasses}
     */
    @Configuration
    class Test1{
        @Bean
        public User user1ByTest1(){
            User user = new User();
            user.setName("user1ByTest1");
            return user;
        }
    }
}
